package org.agilelang.editor;
/*
 AgileLang - A fourth generation language(http://www.agilelang.org).

 Copyright (C) 2013 Roderick Cusirramos (roderick20@hotmail.com)

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import org.agilelang.editor.listener.FileOpenProject;
import org.agilelang.editor.listener.FileSave;
import org.agilelang.editor.listener.FileNewProject;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

public final class ViewToolBar {

    JToolBar tool = new JToolBar();
    ViewFrame frame;
    ViewMenu menu;
    public JButton btnNew;
    public JButton btnOpen;
    public JButton btnSave;
    public JButton btnNewProject;
    public JButton btnPreferences;
    public JButton btnGenerate;

    ViewToolBar(ViewMenu menu1,ViewFrame frame) {
        this.menu = menu1;
        this.frame = frame;
        tool.setOrientation(JToolBar.HORIZONTAL);
        tool.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        tool.setRollover(true);
               
        btnOpen = createToolBarItem("Open", "document-open.png");
        btnOpen.addActionListener(new FileOpenProject(frame));
        
        btnSave = createToolBarItem("Save", "media-floppy.png");
        btnSave.addActionListener(new FileSave(frame));
        
        btnNewProject = createToolBarItem("New Project", "applications-other.png");
        btnNewProject.addActionListener(new FileNewProject(frame));
        
        //btnPreferences = createToolBarItem("Preferences", "preferences-system.png");
        //btnPreferences.addActionListener(btnPreferences());
        
        /*btnGenerate = createToolBarItem("Generate", "applications-system.png");
        btnGenerate.addActionListener(btnGenerate());*/

        tool.add(btnNewProject);
        tool.addSeparator();
        //tool.add(btnNew);
        tool.add(btnOpen);
        tool.add(btnSave);
        tool.addSeparator();
        //tool.add(btnPreferences);
        //tool.addSeparator();
        //tool.add(btnGenerate);
    }

    public JToolBar getToolBar() {
        return tool;
    }

    public ViewToolBar() {
        
    }

    public JButton createToolBarItem(String titulo, String imagen) {
        JButton button = new JButton(new ImageIcon(getIconImage("org/agilelang/editor/resources/img22/" + imagen)));
        button.setToolTipText(titulo);
        return button;
    }

    public Image getIconImage(String urlimagen) {
        Image retValue = Toolkit.getDefaultToolkit().
                getImage(ClassLoader.getSystemResource(urlimagen));
        return retValue;
    }

   

  

   

    private ActionListener btnGenerate() {
        return menu.plugins();
        
    }
}
